package com.prs.moa.usermanager.action;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.prs.core.workflow.dto.Document;
import com.prs.core.workflow.service.WorkFlowEngine;
import com.prs.um.usermanager.dao.UserDAO;
import com.prs.um.usermanager.dto.User;

@Controller
public class UserAction {
	@Resource
	private UserDAO userDAO;
	
	@Resource
	private WorkFlowEngine engine;
	
	@RequestMapping(value = "user!login.action")
	public String addUser(HttpServletRequest request) {
//		User user = new User();
//		user.setLoginId("aaaa");
//		user.setPassword("111");
//		user.setState(1);
//		user.setSupervisorId(null);
//		user.setUsername("asdasd");
//		user.setId("402883493c1904ac013c1904b1e90000");
//		Set<User> userList = new HashSet<User>();
//		userList.add(user);
//		user = this.userDAO.addUser(user);
		Map<String, Object> conditions = new HashMap<String, Object>();
		conditions.put("key", "MyProcess");
		Document document = new Document();
		document.setTitle("MyTest");
		document.setStatus(1);
		
		conditions.put("document", document);
		engine.startProcessByKey(conditions);
		//engine.deployProcess();
		return "main";
	}
}
